﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Net;

public partial class Police_TranslateApprove_IntroduceLetter : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        ExportData("application/ms-Word", DateTime.Now.ToString("yyMdHm") + ".doc");
    }

    private void ExportData(string FileType, string FileName)
    {
        Response.Charset = "GB2312";
        Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");

        Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
        Response.ContentType = FileType;
        this.EnableViewState = false;
        StringWriter tw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(tw);
        Main.RenderControl(hw);
        Response.Write(tw.ToString());
        Response.End();
    }

    public override void VerifyRenderingInServerForm(Control control)
    {
        //base.VerifyRenderingInServerForm(control);
    }
    protected void BtnPrint_Click(object sender, EventArgs e)
    {
        Uri url = new Uri("http://localhost:7570/Web/Default.aspx");
        HttpWebRequest HR = WebRequest.Create(url) as HttpWebRequest;
        HttpWebResponse HRP = HR.GetResponse() as HttpWebResponse;
        HR.Method = "Get";
        HR.KeepAlive = false;
        StreamReader reader = new StreamReader(HRP.GetResponseStream(), System.Text.Encoding.UTF8);
        string TempStr = reader.ReadToEnd()+" <script languge='Javascript'>WebBrowser.ExecWB(6,1); window.opener=null;window.close();</script>";
        Response.Write(TempStr);
    }
}
